package arrAndstr;

public class T12 {

    public static void main(String[] args) {
        int s = 3749;
        System.out.println(intToRoman(s));
    }

    public static String intToRoman(int num) {
        int tempValue = num % 10;
        String G = getStr(tempValue, "I", "V", "X");
        num /= 10;
        if (num <= 0)   return G;

        tempValue = num % 10;
        String S = getStr(tempValue, "X", "L", "C");
        num /= 10;
        if (num <= 0)   return S + G;

        tempValue = num % 10;
        String B = getStr(tempValue, "C", "D", "M");
        num /= 10;
        if (num <= 0)   return B+S+G;

        String Q = getStr(num, "M", "", "");
        return Q + B + S + G;
    }

    private static String getStr(int tempValue, String I, String V, String X) {
        switch (tempValue){
            case 1: return I;
            case 2: return I + I;
            case 3: return I + I + I;
            case 4: return I + V;
            case 5: return V;
            case 6: return V + I;
            case 7: return V + I + I;
            case 8: return V + I + I + I;
            case 9: return I + X;
        }
        return "";
    }
}
